package com.atguigu.demojuc.chap02;

import java.util.concurrent.locks.ReentrantLock;

//ReentrantLock 具有可重入性的互斥锁。
public class ReentrantLockDemo2 {

    ReentrantLock lock = new ReentrantLock();

    public synchronized void a(){
        lock.lock();
        System.out.println("a");
        this.b();
        lock.unlock();
    }
    public synchronized void b(){
        lock.lock();
        System.out.println("b");
        lock.unlock();
    }

    public static void main(String[] args) {
        new ReentrantLockDemo2().a();
    }
}